package go_framework

import "net/http"

//应用数据结构
type Application struct{
	Name string
	Version string
	Routers  map[string]*Route
}

func NewApp() *Application{
	return &Application{
		Name:"",
		Version:"",
		Routers:map[string]*Route{},
	}
}

//应用基本信息-名
func (app Application) AppName()string{
	return app.Name
}

//添加路由
func (app *Application) Router(route string) *Route {
	if _, ok := app.Routers[route]; ok {
		return app.Routers[route]
	}
	app.Routers[route] = &Route{Route: route}
	return app.Routers[route]
}

//运行应用
func (app Application) Run(port string) error{
	return  http.ListenAndServe(port, nil)
}

